package com.cloud.tsp.controller;

import com.cloud.api.domain.algorithm.VehiclePoint;
import com.cloud.api.domain.report.*;
import com.cloud.log.annotation.Log;
import com.cloud.log.enums.BusinessType;
import com.cloud.log.enums.OperatorType;
import com.cloud.mybatis.domain.PageModelNew;
import com.cloud.mybatis.domain.TableDataInfo;
import com.cloud.tsp.service.IArealDistributionService;
import com.cloud.tsp.service.IEvStatisticsService;
import com.cloud.tsp.service.IVehicleAlarmService;
import com.cloud.tsp.service.IVehicleMessageDailyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杨斌
 * 2025-01-2025-01-14
 */
@RestController
@RequestMapping("/report")
public class VehicleReportStatistics {
    @Resource
    private IEvStatisticsService evStatisticsService;

    @Resource
    private IVehicleMessageDailyService vehicleMessageDailyService;

    @Resource
    private IArealDistributionService arealDistributionService;

    @Resource
    private IVehicleAlarmService vehicleAlarmService;


    @Tag(name = "v1.0")
    @Operation(summary = "离线车辆数据导出")
    @PostMapping("/exportOfflineList")
    @Log(title = "离线车辆数据导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportOfflineList(HttpServletResponse response) {
        vehicleMessageDailyService.exportOfflineList(response);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询离线车辆数据")
    @PostMapping("/selectOfflineList")
    @Log(title = "查询离线车辆数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehicleOffline> selectOfflineList(@RequestBody @Valid PageModelNew para) {
        return vehicleMessageDailyService.selectOfflineList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "报警数据导出")
    @PostMapping("/exportAlarmReportList")
    @Log(title = "报警数据导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportAlarmReportList(QueryAlarmReport para, HttpServletResponse response) {
        vehicleAlarmService.exportAlarmList(para, response);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询报警数据")
    @PostMapping("/selectAlarmReportList")
    @Log(title = "查询报警数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehicleAlarmReport> selectAlarmReportList(@RequestBody @Valid QueryAlarms para) {
        return vehicleAlarmService.selectAlarmList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "区域分布省市车辆数据导出")
    @PostMapping("/exportArealDistributionList")
    @Log(title = "区域分布省市车辆数据导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportArealDistributionList(HttpServletResponse response) {
        arealDistributionService.exportArealDistributionList(response);
    }
    @Tag(name = "v1.0")
    @Operation(summary = "查询区域分布省市车辆数据")
    @PostMapping("/selectArealDistributionList")
    @Log(title = "查询区域分布省市车辆数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<ArealDistributionExcel> selectArealDistributionList(@RequestBody @Valid PageModelNew para) {
        return arealDistributionService.selectArealDistributionList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "省市车辆运行情况导出")
    @PostMapping("/exportProvinceDistributionList")
    @Log(title = "省市车辆运行情况导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportProvinceDistributionList(QueryDistribution para, HttpServletResponse response) {
        evStatisticsService.exportProvinceDistributionList(para, response);
    }
    @Tag(name = "v1.0")
    @Operation(summary = "查询查询省市车辆运行情况")
    @PostMapping("/selectProvinceDistributionList")
    @Log(title = "查询省市车辆运行情况", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<ProvinceDistribution> selectProvinceDistributionList(@RequestBody @Valid QueryProvinceDistribution para) {
        return evStatisticsService.selectProvinceDistributionList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "车辆上线情况导出")
    @PostMapping("/exportVehiclesOnLineList")
    @Log(title = "车辆上线情况导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportVehiclesOnLineList(QueryDistribution para, HttpServletResponse response) {
        evStatisticsService.exportVehiclesOnLineList(para, response);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询车辆上线情况")
    @PostMapping("/selectVehiclesOnLineList")
    @Log(title = "查询车辆上线情况", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehiclesOnLine> selectVehiclesOnLineList(@RequestBody @Valid QueryProvinceDistribution para) {
        return evStatisticsService.selectVehiclesOnLineList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "车型运行情况导出")
    @PostMapping("/exportVehiclesModelList")
    @Log(title = "车型运行情况导出", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportVehiclesModelList(QueryDistribution para, HttpServletResponse response) {
        evStatisticsService.exportVehiclesModelList(para, response);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询车型运行情况")
    @PostMapping("/selectVehiclesModelList")
    @Log(title = "查询车型运行情况", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehicleModelCondition> selectVehiclesModelList(@RequestBody @Valid QueryProvinceDistribution para) {
        return evStatisticsService.selectVehiclesModelList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "能耗数据分析(月)导出数据")
    @PostMapping("/exportVehiclesEnergyList")
    @Log(title = "能耗数据分析(月)导出数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportVehiclesEnergyList(QueryDistribution para, HttpServletResponse response) {
        evStatisticsService.exportVehiclesEnergyList(para, response);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询能耗数据分析(月)数据")
    @PostMapping("/selectVehiclesEnergyList")
    @Log(title = "查询能耗数据分析(月)数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehiclesEnergy> selectVehiclesEnergyList(@RequestBody @Valid QueryProvinceDistribution para) {
        return evStatisticsService.selectVehiclesEnergyList(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "查询聚集停放车辆")
    @PostMapping("/getAggVehicleMessage")
    @Log(title = "查询聚集停放车辆数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public TableDataInfo<VehiclePoint> getAggVehicleMessage(@RequestBody @Valid PageModelNew para) {
        return vehicleMessageDailyService.getAggVehicleMessage(para);
    }

    @Tag(name = "v1.0")
    @Operation(summary = "导出聚集停放车辆数据")
    @PostMapping("/exportAggVehicleMessage")
    @Log(title = "导出聚集停放车辆数据", businessType = BusinessType.EXPORT, operatorType = OperatorType.MANAGE)
    public void exportAggVehicleMessage(HttpServletResponse response) {
         vehicleMessageDailyService.exportAggVehicleMessage(response);
    }


}
